<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html><head>
<title>hg.app.recurse</title>
<style>
body {
    background:white;
    margin: 0em 1em 10em 1em;
    color: black;
}

h1 { color: white; background: #4FA4FF; }
h2 { color: white; background: #4FA4FF; }
h3 { color: white; background: #00557F; }
h4 { color: white; background: #00557F; }
    
a { color: #AA5500; }

</style>
</head>
<body><a NAME="top" ID="top"></a>
<h1>hg.app.recurse</h1>

<h3>Global Attributes</h3>
<table>
<tr><td>do_recurse</td></tr><tr><td>register</td></tr>
</table>
<h3>Classes</h3>
<table>
<tr>
<td><a href="#RecurseNode">RecurseNode</a></td>
<td></td>
</tr>
</table>
<h3>Functions</h3>
<table>
<tr>
<td><a href="#convert">convert</a></td>
<td></td>
</tr><tr>
<td><a href="#do_recurse">do_recurse</a></td>
<td>Recursively loops over each item in an array .</td>
</tr><tr>
<td><a href="#tError">tError</a></td>
<td></td>
</tr>
</table>
<hr /><hr />
<a NAME="RecurseNode" ID="RecurseNode"></a>
<h2>RecurseNode</h2>

<h3>Derived from</h3>
Node
<h3>Class Attributes</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Methods</h3>
<table>
<tr>
<td><a href="#RecurseNode.__init__">RecurseNode</a></td>
<td></td>
</tr><tr>
<td><a href="#RecurseNode.__iter__">__iter__</a></td>
<td></td>
</tr><tr>
<td><a href="#RecurseNode.__repr__">__repr__</a></td>
<td></td>
</tr><tr>
<td><a href="#RecurseNode.get_nodes_by_type">get_nodes_by_type</a></td>
<td></td>
</tr><tr>
<td><a href="#RecurseNode.render">render</a></td>
<td></td>
</tr>
</table>
<a NAME="RecurseNode.__init__" ID="RecurseNode.__init__"></a>
<h4>RecurseNode (Constructor)</h4>
<b>RecurseNode</b>(<i>**kwargs</i>)
<a NAME="RecurseNode.__iter__" ID="RecurseNode.__iter__"></a>
<h4>RecurseNode.__iter__</h4>
<b>__iter__</b>(<i></i>)
<a NAME="RecurseNode.__repr__" ID="RecurseNode.__repr__"></a>
<h4>RecurseNode.__repr__</h4>
<b>__repr__</b>(<i></i>)
<a NAME="RecurseNode.get_nodes_by_type" ID="RecurseNode.get_nodes_by_type"></a>
<h4>RecurseNode.get_nodes_by_type</h4>
<b>get_nodes_by_type</b>(<i>nodetype</i>)
<a NAME="RecurseNode.render" ID="RecurseNode.render"></a>
<h4>RecurseNode.render</h4>
<b>render</b>(<i>context, depth=0, values=False</i>)

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="convert" ID="convert"></a>
<h2>convert</h2>
<b>convert</b>(<i>val</i>)

<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="do_recurse" ID="do_recurse"></a>
<h2>do_recurse</h2>
<b>do_recurse</b>(<i>parser, token</i>)
<p>
    Recursively loops over each item in an array . 
    It also increments passed variables on each recursion depth.
    For example, to display a list of comments with replies given ``comment_list``:
</p><p>
      {% recurse comment in comments children="replies" indent=(0,20) %}
          <div style="margin-left:{{indent}}px">{{ comment.text }}</div>
      {% endrecurse %}
</p><p>
    ``children`` is the name of the iterable that contains the children of the current element
    ``children`` needs to be a property of comment, and is required for the recurseloop to work
    You can pass additional parameters after children in the form of:
</p><p>
      var_name=(intial_value, increment)
</p><p>
    You need to take care of creating the tree structure on your own.
    As for now there should be no spaces between the equal ``=`` 
    signs when assigning children or additional variables
</p><p>
    In addition to the variables passed, the recurse loop sets a 
    number of variables available within the loop:
        ==========================  ================================================
        Variable                    Description
        ==========================  ================================================
        ``recurseloop.depth``       The current depth of the loop (1 is the top level)
        ``recurseloop.depth0``      The current depth of the loop (0 is the top level)
        ``recurseloop.counter``     The current iteration of the current level(1-indexed)
        ``recurseloop.counter0``    The current iteration of the current level(0-indexed)
        ``recurseloop.first``       True if this is the first time through the current level
        ``recurseloop.last``        True if this is the last time through the current level
        ``recurseloop.parent``      This is the loop one level "above" the current one
        ==========================  ================================================
</p><p>
    You can also use the tag {% yield %} inside a recursion.
    The ``yield`` tag will output the same HTML that's between the recurse and endrecurse tags
    if the current element has children. If there are no children ``yield`` will output nothing
    You must not, however wrap the ``yield`` tag inside other tags, just like you must not wrap
    the ``else`` tag inside other tags when making if-else-endif 
</p>
<div align="right"><a href="#top">Up</a></div>
<hr /><hr />
<a NAME="tError" ID="tError"></a>
<h2>tError</h2>
<b>tError</b>(<i>contents</i>)

<div align="right"><a href="#top">Up</a></div>
<hr />
</body></html>